﻿using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;

namespace DKPScoreWebApi.Models
{
    /// <summary>
    /// 工会管理员实体类
    /// 记录工会的管理员权限信息
    /// </summary>
    public class GuildAdmin
    {
        /// <summary>
        /// 管理员记录ID，主键，自增
        /// </summary>
        [Key]
        public int Id { get; set; }

        /// <summary>
        /// 工会ID，外键关联Guild
        /// </summary>
        [Required]
        public int GuildId { get; set; }

        /// <summary>
        /// 用户ID，外键关联WxUser
        /// </summary>
        [Required]
        public int UserId { get; set; }

        /// <summary>
        /// 管理员角色：owner(所有者)、admin(管理员)、member(成员)
        /// </summary>
        [Required]
        [MaxLength(20)]
        public string Role { get; set; } = "admin"; // "owner", "admin", "member"

        /// <summary>
        /// 添加者ID，记录是谁添加的这个管理员
        /// </summary>
        [Required]
        public int AddedBy { get; set; }

        /// <summary>
        /// 添加时间
        /// </summary>
        public DateTime AddedAt { get; set; } = DateTime.Now;

        // 导航属性
        /// <summary>
        /// 所属工会信息
        /// </summary>
        [ForeignKey("GuildId")]
        public virtual Guild Guild { get; set; }

        /// <summary>
        /// 用户信息
        /// </summary>
        [ForeignKey("UserId")]
        public virtual WxUser User { get; set; }

        /// <summary>
        /// 添加者信息
        /// </summary>
        [ForeignKey("AddedBy")]
        public virtual WxUser AddedByUser { get; set; }
    }
}
